package com.hxc.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hxc.dao.NewsMapper;
import com.hxc.pojo.News;
import com.hxc.pojo.NewsExt;
import com.hxc.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NewsServiceImpl implements NewsService{

    @Autowired
    private NewsMapper newsMapper;

    @Override
    public List<News> findAll() {
        return newsMapper.findAll();
    }

    @Override
    public void deleteAll(List<Object> list) {
        for(Object i:list){
            newsMapper.delete(i);
        }
    }

    @Override
    public PageInfo<NewsExt> getNewsList(NewsExt newsExt, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize,"id desc");
        List<NewsExt> newsList=newsMapper.getNewsList(newsExt);
        PageInfo<NewsExt> pageInfo=new PageInfo<>(newsList,5);
        return pageInfo;
    }
}
